package com.yuncheng.spcyApi.service.impl;

import cn.hutool.core.bean.BeanUtil;


import com.yuncheng.spcyApi.constant.common.LogConstant;
import com.yuncheng.spcyApi.constant.common.SpcyConstant;
import com.yuncheng.spcyApi.entity.SpcyRsJcxm;
import com.yuncheng.spcyApi.mapper.SpcyRsJcxmMapper;
import com.yuncheng.spcyApi.service.ISpcyLogService;
import com.yuncheng.spcyApi.service.ISpcyRsJcxmService;
import com.yuncheng.spcyApi.utils.GetCurrentUserUtils;
import com.yuncheng.spcyApi.utils.GetUuIdUtils;

import com.yuncheng.vo.CurrentUserVo;
import org.springframework.stereotype.Service;

import com.yuncheng.common.base.service.impl.BaseServiceImpl;
import utils.LogUtils;
import utils.ObjectToMapUtils;

import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;

/**
 * @Description: 审评查验-检查项目库
 * @Author: csx
 * @Date: 2023-03-03
 * @Version: V1.0
 */
@Service
public class SpcyRsJcxmServiceImpl extends BaseServiceImpl<SpcyRsJcxmMapper, SpcyRsJcxm> implements ISpcyRsJcxmService {

    @Resource
    private SpcyRsJcxmMapper spcyRsJcxmMapper;

    @Resource
    private ISpcyLogService spcyLogService;

    @Override
    public void impRsJcxmData(Map map, String ywflCode) {
        SpcyRsJcxm spcyRsJcxm = new SpcyRsJcxm();
        BeanUtil.copyProperties(map, spcyRsJcxm); // 复制数据

        String rsJcXmId = GetUuIdUtils.ReplaceUuId();
        spcyRsJcxm.setId(rsJcXmId);
        spcyRsJcxm.setFywflcode(ywflCode);
        spcyRsJcxm.setCreateTime(new Date());
        CurrentUserVo currentUser = GetCurrentUserUtils.getCurrentUser();
        if (currentUser != null){
            spcyRsJcxm.setCreateBy(currentUser.getName());
        }
        spcyRsJcxmMapper.insert(spcyRsJcxm);

        /*String OperContent = "新增导入信息: ";
        Map<String, Object> jcxmMap = ObjectToMapUtils.objectToMap(spcyRsJcxm);
        OperContent += LogUtils.MapToStringMethod(jcxmMap);
        spcyLogService.addLogs(LogConstant.LOGS_RS_JCXM, OperContent,rsJcXmId,LogConstant.LOGS_RS_JCXM, SpcyConstant.LOGS_SYS_TYPE_XZ);*/
    }
}
